from django.shortcuts import render
from django.template.loader import get_template
from django.template import Context
from django.http import HttpResponse

# Create your views here.
def login_view(request):
    t = get_template('../templates/login.tpl')
    html = t.render(Context({'current_date': 'ADMIN'}))
    return HttpResponse(html)

def changePassword_view(request):
    t = get_template('../templates/changepassword.tpl')
    html = t.render(Context({'current_date': 'ADMIN'}))
    return HttpResponse(html)

def login():
    username = request.POST['username']
    password = request.POST['password']
    user = auth.authenticate(username=username, password=password)
    if user is not None and user.is_active:
        # Correct password, and the user is marked "active"
        auth.login(request, user)
        # Redirect to a success page.
        return HttpResponseRedirect("/account/loggedin/")
    else:
        # Show an error page
        return HttpResponseRedirect("/account/invalid/")
    

def changepassword():
    pass